<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:p="http://primefaces.org/ui"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:ch="http://java.sun.com/jsf/composite/channel"
                xmlns:pe="http://primefaces.org/ui/extensions"
                xmlns:au="http://java.sun.com/jsf/composite/autocomplete">

    <ui:define name="content">

        <h:form>

            <p:panel>
                <f:facet name="header">
                    <p:outputLabel value="Consultant Wise Appoinment Totals And Count(Can't Consider Appoinment Time)" />
                    <p:commandButton id="btnBack" value="Back" 
                                     action="/channel/channel_reports" style="float: right;"
                                     ajax="false">
                    </p:commandButton>
                </f:facet>

                <p:panel id="pan1">
                    <h:panelGrid columns="2" >
                        <h:outputLabel value="From Date"/>
                        <p:calendar value="#{channelReportTempController.fromDate}" navigator="true" pattern="dd MMM yyyy hh:mm:ss a" styleClass="dateTimePicker"  >
                        </p:calendar>
                        <h:outputLabel value="To Date"/>
                        <p:calendar value="#{channelReportTempController.toDate}" navigator="true" pattern="dd MMM yyyy hh:mm:ss a" styleClass="dateTimePicker" >
                        </p:calendar>
                        <h:outputLabel value="Staff" rendered="#{!channelReportTempController.paid}"/>
                        <p:autoComplete minQueryLength="2"  style="width: 400px;"
                                        forceSelection="true" placeholder="Staff"
                                        value="#{channelReportTempController.reportKeyWord.staff}" id="scStaff"
                                        completeMethod="#{channelStaffPaymentBillController.completeStaff}" var="mys" 
                                        itemLabel="#{mys.person.nameWithTitle}" itemValue="#{mys}"
                                        converter="stfcon" rendered="#{!channelReportTempController.paid}"   >                                            
                        </p:autoComplete>
                        <h:outputLabel value="Specility" rendered="#{!channelReportTempController.paid}"/>
                        <au:completeSpeciality value="#{channelReportTempController.reportKeyWord.speciality}" rendered="#{!channelReportTempController.paid}" />
                    </h:panelGrid>
                    <h:panelGrid columns="2" id="pg1" >
                        <h:outputLabel value="By Date"/> 
                        <p:selectBooleanCheckbox value="#{channelReportTempController.byDate}" />
                        <h:outputLabel value="By Specility"/> 
                        <p:selectBooleanCheckbox value="#{channelReportTempController.paid}" >
                            <f:ajax event="change" execute="@this" render="pan1" />
                        </p:selectBooleanCheckbox>
                    </h:panelGrid> 
                    <h:panelGrid columns="3">
                        <p:commandButton action="#{channelReportTempController.createStaffWiseAppoinmentCountNew}" rendered="#{!channelReportTempController.paid}" value="Count" ajax="false" />
                        <p:commandButton action="#{channelReportTempController.createSpecilityWiseAppoinmentCountNew()}" rendered="#{channelReportTempController.paid}" value="Count" ajax="false" />
                        <p:commandButton ajax="false" value="Print" styleClass="noPrintButton">
                            <p:printer target="reportPrint"  />
                        </p:commandButton>
                        <p:commandButton ajax="false" value="Excel" styleClass="noPrintButton" onclick="onSubmitButton();" >
                            <pe:exporter type="xlsx" target="tbl1" fileName="Channel_Count"  />
                        </p:commandButton>
                    </h:panelGrid>
                </p:panel>
                <p:panel id="reportPrint" >
                    <!--                    <table border="1" style="border: 1px solid black;">
                                            <tr>
                                                <th>Consultant</th>
                                                <ui:repeat value="#{channelReportTempController.headers}" var="h" >
                                                    <th style="white-space: nowrap;">
                    #{h}
                </th>
            </ui:repeat>
        </tr>
        <ui:repeat value="#{channelReportTempController.channelDoctorCountsRows}" var="d" >
            <tr>
                <td style="white-space: nowrap;">
                    #{d.staff.person.name} 
                </td>
                <ui:repeat value="#{d.counts}" var="c" >
                    <td >
                        <center>#{c}</center>
                    </td>
                </ui:repeat>
            </tr>
        </ui:repeat>
    </table>-->
                    <p:dataTable id="tbl1" value="#{channelReportTempController.channelDoctorCountsRows}" var="s">
                        <p:column rendered="#{!channelReportTempController.paid}">
                            <f:facet name="header">
                                <h:outputText value="Doctor Name"/>
                            </f:facet>
                            <h:outputText value="#{s.staff.person.name}" rendered="#{s.staff ne null}"/>
                            <h:outputText value="Total" rendered="#{s.staff eq null}"/>
                        </p:column>
                        <p:column rendered="#{channelReportTempController.paid}">
                            <f:facet name="header">
                                <h:outputText value="Specility Name"/>
                            </f:facet>
                            <h:outputText value="#{s.speciality.name}" rendered="#{s.speciality ne null}"/>
                            <h:outputText value="Total" rendered="#{s.speciality eq null}"/>
                        </p:column>
                        <p:columns value="#{channelReportTempController.columnModels}" var="column" styleClass="numberCol">
                            <f:facet name="header">
                                <h:outputText value="#{column.header}" />
                            </f:facet>
                            <h:outputText value="#{s.counts[column.property]}" >
                                <f:convertNumber pattern="#,##0" />
                            </h:outputText>
                        </p:columns>


                    </p:dataTable>
                </p:panel>

            </p:panel>

        </h:form>
    </ui:define>


</ui:composition>